<layout name='Layout/layout_main' />
<script type="text/javascript">


    function save(){
		if ($("#customer_name").val().length > 0) {
			$("#customer_name", parent.document).val($("#customer_name").val());
			$("#customer_id", parent.document).val($("#customer_id").val());
                        $("#phone_num", parent.document).val($("#phone_num").val());
                        $('.l-dialog-btn-inner',parent.document).click();
		} else {
			alert("请选择客户");
		}
		
    }


	function key_search_2() {
		if (event.keyCode == 13){
			$(".table li").hide();			
			val = $("#keyword").val().toUpperCase();
			if (val.length == 0) {
				$(".title nobr").html("全部");
			} else {
				$(".title nobr").html("搜索结果");
			}
			$(".table li .data").each(function() {
				if ($(this).text().indexOf(val) >= 0) {
					$(this).parents("li").show();
				};
			})
		}
	}

	function btn_search_2() {		
		$(".table li").hide();			
		val = $("#keyword").val().toUpperCase();
		if (val.length == 0) {
			$(".title nobr").html("全部");
		} else {
			$(".title nobr").html("搜索结果");
		}
		$(".table li .data").each(function() {
			if ($(this).text().indexOf(val) >= 0) {
				$(this).parents("li").show();
			};
		})		
	}


      function chose_customer(sid,customer_id,customer_name,phone_num){
        $(".tbody").removeClass("active");
	$('#'+sid).addClass("active");
        $("#customer_name").val(customer_name);
         $("#customer_id").val(customer_id);
         $("#phone_num").val(phone_num);
    }

</script>
<div class="customer">
	<div class="row-fluid title">
		<div class="btn-group">
			<span class="btn dropdown-toggle no-border" data-toggle="dropdown" href="#">
				<nobr>全部</nobr> <i class="icon-caret-down"></i>
			</span>
			<ul class="dropdown-menu title">
				<li gid="">
					<a>全部</a>
				</li>
				<foreach name="group_list" item="vo">
					<li gid="{$key}">
						<a>{$vo}</a>
					</li>
				</foreach>
			</ul>
		</div>
		<div class="input-append right">
			<input type="text"  onkeydown="key_search_2();" name="keyword" id="keyword">
			<a class="btn" onclick="btn_search_2();"> <i class="icon-search"></i> 
			</a>&nbsp;
       <input type="button" class="btn" name="btn_select_dept" value="确定" onclick="save();">
       
       <input type="hidden" value="" id="customer_name" name="customer_name" />
        <input type="hidden" value="" id="customer_id" name="customer_id" />
         <input type="hidden" value="" id="phone_num" name="phone_num" />
		</div>
	</div>
	<form id="form_data" name="form_data" method='post'>
		<div id="list" name="list" class="table">
			<ul>
				<if condition="count($list) eq 0 ">
					<li class="tbody text-center">
						<h3>没找到相应的数据</h3>
					</li>
				</ul>
			</div>
			<else/>
			<foreach name="list" item="vo">
				<li  onclick=chose_customer(this.id,'{$vo.id}','{$vo.name}','{$vo.mobile_tel}') class='tbody' id='D{$vo.id}' >
					<span class="checkbox" >
						<input type="hidden" name="customer_id" value="{$vo.id}" ></span>
					<div class="auto">
						<div class="row-fluid">
								<a href="{:U('read?id='.$vo['id'])}" class="data">{$vo.name}</a>
								<nobr>业务员：</nobr>
								<nobr class="data">{$vo.salesman}</nobr>
						</div>
						<div class="row-fluid">
								<nobr>联系人：</nobr>
								<nobr class="data">{$vo.contact}</nobr>
								<nobr>手机：</nobr>
								<nobr class="data">
									{$vo.mobile_tel}
									<notempty name="vo.mobile_tel">/ {$vo.mobile_tel}</notempty>
								</nobr>
						</div>
					</div>
				</li>
			</foreach>
		</ul>
	</div>
</form>
 <div class="page">
	{$page}
</div>
</if>
</div>